#ifndef AUTHDIALOG_H
#define AUTHDIALOG_H


#include <QDialog>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <Interfaces/tray.h>
#include <QMessageBox>
#include <QNetworkProxy>
#include <registredialog.h>
#include <QCloseEvent>
#include <QScopedPointer>

class Tray;

namespace Ui {
    class AuthDialog;
}

class AuthDialog : public QDialog
{
    Q_OBJECT

public:
    explicit AuthDialog(QWidget *parent = 0);
    ~AuthDialog();
    //void SetTrayHandle(Tray*);
    bool OnLoad();

    bool inline IsUserAuth(){return is_auth;}
private:
    Ui::AuthDialog *ui;
    QNetworkAccessManager *manager;
    QUrl auth_url;
    QNetworkRequest req;
    //Tray *tray_handle;
    bool is_auth;
    QString login;
    QString password;
    bool is_saved;
    QMessageBox MessageBox;
    QNetworkProxy proxy;
    RegistreDialog RegDialog;
    void closeEvent ( QCloseEvent * e );
private slots:
    void onRegistrationButtonClicked();
    void onOkButtonClicked();
    void onExitButtonClicked();
    void onFinished(QNetworkReply*);

signals:
    void success();
};

#endif // AUTHDIALOG_H
